package com.itboye.eweilisten.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.eweilisten.R;
import com.itboye.eweilisten.model.YesCuoBean;

/**
 * 错题详情
 */
public class ScoreReparAdapter extends BaseAdapter {

    Context context;
    YesCuoBean bean;

    public ScoreReparAdapter(Context context, YesCuoBean bean) {
        this.context = context;
        this.bean = bean;

    }

    @Override
    public int getCount() {
        return bean.getList().size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHouder houder;
        if (convertView == null) {
            houder = new ViewHouder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_gridview_chengji, null);
            houder.tvName = (TextView) convertView.findViewById(R.id.tvChengJi);
            convertView.setTag(houder);
        } else {
            houder = (ViewHouder) convertView.getTag();
        }

        houder.tvName.setText(position + 1 + "");

        //0对  1错 2漏
        if (bean.getList().get(position).getAnswer_type() != null) {
            if (bean.getList().get(position).getAnswer_type().equals("0")) {
                houder.tvName.setBackgroundResource(R.drawable.text_view_shape);
            } else if (bean.getList().get(position).getAnswer_type().equals("1")) {
                houder.tvName.setBackgroundResource(R.drawable.text_hongse);
            } else if (bean.getList().get(position).getAnswer_type().equals("2")) {
                houder.tvName.setBackgroundResource(R.drawable.text_huangse);
            }
        }
            return convertView;
    }

    public class ViewHouder {
        TextView tvName;
    }
}
